﻿using CKS.Core.Framework;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using ZR.Model.Models.ProductionControl;

namespace CKS.PLC.Action.Subscription.OP100
{
    /// <summary>
    /// 动作编号1
    /// 1号钎焊料架放满上传请求
    /// </summary>
    public class DB3011_Work01Action : PLCAction
    {
        public DB3011_Work01Action(DecodeValue _value) : base(_value)
        {
        }
        public override void Execute()
        {
            var result = Value.Value.ToInt();
            var replayDB = 3010;
            var replayAction = 1;
            if (result == 1)
            {

                DcCoverrivetingassemble dc = new DcCoverrivetingassemble();


                //var arr1 =Value.GetLinkData(1).Adapt<List<int>>();
                //var arr2 = Value.GetLinkData(2).Adapt<List<int>>();

                // db.Insertable(dc).ExecuteCommand();

                //保存数据
                //读取子篮二维码和检测结果
                //string barcode = Value.GetLinkData(1).ToString();
                //int flag = Value.GetLinkData(2).ToInt();
                //		BC022407080135 BC022406200879 BC022407080087
                /*
                 		
	
                	
	
                 */
                //logger.LogInformation($"保存数据 子篮码{barcode} 检测结果{flag}");
                //查找保存完成点位
                EventBus.AddLog("OP100请求保存数据");
                var replayPos = Value.GetPosition(replayDB, replayAction);
                AckWriteInt16(replayPos, 1);
            }
            else
            {
                var replayPos = Value.GetPosition(replayDB, replayAction);
                AckWriteInt16(replayPos, 0);
                EventBus.AddLog("OP100 重置保存状态");
                logger.LogInformation($"OP100 重置保存状态");
            }
        }
    }
}
